package ua.epam.java_bravo.controller.servletCommand;

import ua.epam.java_bravo.manager.ConfigurationManager;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: Linderhof
 * Date: 15.12.2010
 * Time: 13:50:15
 */
public class AddrFormCommand implements ICommand{
    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String page = null;

        //Extracting Address fields from request
        String id = request.getParameter("id");
        String street = request.getParameter("street");
        String house = request.getParameter("house");
        String flat = request.getParameter("flat");

        //setting the response attributes
        request.setAttribute("id", id);
        request.setAttribute("street", street);
        request.setAttribute("house", house);
        request.setAttribute("flat", flat);

        //path to resulting .jspx page
        page = ConfigurationManager.getInstance().
                getProperty(ConfigurationManager.ADDR_VIEW_PATH);

        return page;
    }
}
